import { render, connect } from '../../../../../hrpub/common/frame'
import PubAction from '../../actions/pub';
import Emptyimg from '../../../../../hrpub/common/components/emptyImg'
import BodyAction from './actions/body';
import Pagination from '../../../../../hrpub/common/components/Pagination'
import 'src/hrpub/common/static/style/aboutModal.less'

const Table = render({
    actions: {
        pubAction: PubAction,
        bodyAction: BodyAction
    }
})(({ props, action, state }) => {
    const { main, editTable, button } = props
    const { createEditTable } = editTable
    const { createButtonApp } = button
    let dom = (main.orgvalue.refpk || main.widget) ?
        <React.Fragment>
            <div style={{ display: main.showPage === 'list' ? '' : 'none' }}>
                <div>
                    {createEditTable('list', {
                        onRowClick : action.bodyAction.onRowClick,
                        onRowDoubleClick: action.bodyAction.onRowDoubleClick,
                        showIndex: true,
                        adaptionHeight: true,
                        otherAreaHeight:main.pageInfo.total ? 50:0,
                        // height: main.pageHeight,
                        cancelCustomRightMenu: true
                    })}
                </div>
            </div>
            <div className="table-bar" style={{ display: main.showPage === 'list' && main.pageInfo.total - 0 > 0 ? '' : 'none' }}>
                <div className="page-pagination" >
                    {main.pageInfo.total ? <Pagination
                        current={main.pageInfo.pageIndex}
                        total={main.pageInfo.total}
                        pageSize={main.pageInfo.pageSize}
                        showQuickJumper={true}
                        showSizeChanger={true}                    
                        onChange={action.bodyAction.paginationEve}
                        onShowSizeChange={action.bodyAction.pageSizeSelect}
                        /> : null}
                </div>
            </div>
            
        </React.Fragment> : <Emptyimg text={main.json['gx6008-000077']} />


    return (
        <React.Fragment>
            {dom}
        </React.Fragment>
        )
})



export default connect(Table)